package com.springboot.springautowired.acquireBean;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

/**
 * @author mac
 * @date 2021/9/16 1:09 下午
 */
@Component
public class MyBeanFactory implements ApplicationContextAware {
    private ApplicationContext context;
    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        this.context = applicationContext;
    }

    public void  obtainBean(){
        Object testServiceOne = context.getBean("testServiceOne");
    }
}
